package org.kl.bpm.repository.conf;

import java.util.List;

import org.kl.bf.repository.BasicRepository;
import org.kl.bpm.entity.conf.BpmKvProp;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

public interface BpmKvPropDao extends BasicRepository<BpmKvProp, String>, JpaSpecificationExecutor<BpmKvProp> {
	List<BpmKvProp> findByTaskId(String taskId);

	List<BpmKvProp> findByTaskDefinitionKeyAndBpmKvRecordRef(String taskDefinitionKey, String processInstanceId);

	List<BpmKvProp> findByBpmKvRecordIdOrderByCreateTimeAsc(String recordId);
	
	List<BpmKvProp> findByBpmKvRecordIdAndCodeOrderByCreateTimeDesc(String recordId,String propCode);
	@Query("select max(taskId)  from BpmKvProp d where d.bpmKvRecord.id=?1 and taskDefinitionKey=?2 and code=?3")
	public String getMaxTaskId(String recordId,String taskDefinitionKey,String code);
	BpmKvProp findByBpmKvRecordIdAndTaskIdAndTaskDefinitionKeyAndCode(String recordId,String taskId,String taskDefinitionKey,String code);

}
